package com.igrowing.api.apitest.controller;


import com.igrowing.api.apitest.model.Animal;

import com.igrowing.api.apitest.model.Location;
import com.igrowing.api.apitest.model.UserTest;


import com.igrowing.api.apitest.utils.RequestUtils;
import okhttp3.WebSocket;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * Description:    // 类说明
 *
 * @ClassName: testCOntroller    // 类名，会自动填充
 * @Author: 周天赐        // 创建者
 * @Email: m18879004515@163.com
 * @Date: 2024/2/28 13:06   // 时间
 * @Version: 1.0     // 版本
 */
@RestController
@RequestMapping("/igrowing")
@CrossOrigin(origins = {"http://122.51.92.142"},allowCredentials = "true")
public class testController {
    @PostMapping("/user")
    public String getNameByJson(@RequestBody UserTest user , HttpServletRequest request){

        System.out.println("Json , 你的名字是"+user.getName());

        return "Json , 你的名字是"+user.getName();
    }

    @GetMapping("/poisonousChickenSoup")
    public String getPoisonousChickenSoup()
    {

        return RequestUtils.get("http://api.btstu.cn/yan/api.php");
    }

    @GetMapping("localweather")
    public String getWeather()
    {
        return RequestUtils.get("https://api.vvhan.com/api/weather");
    }

    @PostMapping("weatherBylocation")
    public String getWeatherByLocation(@RequestBody Location location, HttpServletRequest request)
    {
        return RequestUtils.get("https://api.vvhan.com/api/weather?city="+location.getLocation());
    }

    @GetMapping("joke")
    public String getJoke()
    {
        return RequestUtils.get("https://api.vvhan.com/api/text/joke");
    }

    @GetMapping("english")
    public String getEnglish()
    {
        return RequestUtils.get("https://api.vvhan.com/api/dailyEnglish?type=sj");
    }

    @GetMapping("wallPaper")
    public String getWaller()
    {
        return RequestUtils.get("https://api.vvhan.com/api/dailyEnglish?type=sj");
    }


}

    
    
